package com.thunder.kocho.loki;

import android.animation.Animator;
import java.util.ArrayList;

/**
 * 控制Loki和LokiGroup的动画状态
 * @author Hilex
 * @date 2021-2-22
 */
public class AnimatorUtil {

    public static void start(Animator animator) {
        if (animator != null && !animator.isStarted()) {
            //resetDurationScale();
            animator.start();
        }
    }

    public static void stop(Animator animator) {
        if (animator != null && !animator.isRunning()) {
            animator.end();
        }
    }

    public static void start(ArrayList<Loki> lokis){
        if(lokis!=null&&lokis.size()>0){
            for(Loki loki:lokis){
                loki.start();
            }
        }
    }

    public static void stop(ArrayList<Loki> lokis){
        if(lokis!=null&&lokis.size()>0){
            for(Loki loki:lokis){
                loki.stop();
            }
        }
    }

    public static boolean isRunning(ArrayList<Loki> lokis){
        if(lokis!=null&&lokis.size()>0){
            for(Loki loki:lokis){
                if(isRunning(loki.getAnimator())){
                    return true;
                }
            }
        }
        return false;
    }

    public static boolean isRunning(Animator animator) {
        return animator != null && animator.isRunning();
    }

    public static boolean isStarted(Animator animator) {
        return animator != null && animator.isStarted();
    }

    public static boolean isStarted(ArrayList<Loki> lokis){
        if(lokis!=null&&lokis.size()>0){
            for(Loki loki:lokis){
                if(isStarted(loki.getAnimator())){
                    return true;
                }
            }
        }
        return false;
    }

}
